//
//  WeddingCarDetailBottomView.m
//  BaseProject
//
//  Created by 王洋 on 2021/5/11.
//  Copyright © 2021 王洋. All rights reserved.
//

#import "WeddingCarDetailBottomView.h"

@implementation WeddingCarDetailBottomView

- (void)awakeFromNib {
    [super awakeFromNib];
    
    WEAKSELF
    [self.imControl addGestureTapEventHandle:^(id  _Nonnull sender, UITapGestureRecognizer * _Nonnull gestureRecognizer) {
        if (weakSelf.WeddingCarDetailBottomViewBlock) {
            weakSelf.WeddingCarDetailBottomViewBlock(WeddingCarDetailBottomActionType_im);
        }
    }];
    
    [self.phoneControl addGestureTapEventHandle:^(id  _Nonnull sender, UITapGestureRecognizer * _Nonnull gestureRecognizer) {
        if (weakSelf.WeddingCarDetailBottomViewBlock) {
            weakSelf.WeddingCarDetailBottomViewBlock(WeddingCarDetailBottomActionType_phone);
        }
    }];
    
    [self.carQueueControl addGestureTapEventHandle:^(id  _Nonnull sender, UITapGestureRecognizer * _Nonnull gestureRecognizer) {
        if (weakSelf.WeddingCarDetailBottomViewBlock) {
            weakSelf.WeddingCarDetailBottomViewBlock(WeddingCarDetailBottomActionType_cart);
        }
    }];
    
    if ([BA_BusinessHelper shared].userProportion == 0) {
        self.fanxianLab.hidden = YES;
    } else {
        self.fanxianLab.hidden = NO;
        self.fanxianLab.text = [NSString stringWithFormat:@"支付立返%ld%%",(long)[BA_BusinessHelper shared].userProportion];
    }
    
}

- (void)layoutSubviews {
    [super layoutSubviews];
    dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.01 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
        [self.yuyueBtn pp_clipCorners:UIRectCornerTopLeft|UIRectCornerBottomLeft radius:self.yuyueBtn.frame.size.height/2 border:1 color:UIColorHex(0xFF9D43)];
        [self.buyBtn pp_clipCorners:UIRectCornerTopRight|UIRectCornerBottomRight radius:self.buyBtn.frame.size.height/2];
        self.carQueueControl.frame = self.phoneControl.frame;
    });
    self.phoneControl.hidden = YES;
    self.carQueueControl.frame = self.phoneControl.frame;
}

- (IBAction)subscribeAction:(id)sender {
    if (self.WeddingCarDetailBottomViewBlock) {
        self.WeddingCarDetailBottomViewBlock(WeddingCarDetailBottomActionType_yuyue);
    }
}

- (IBAction)handleAction:(id)sender {
    if (self.WeddingCarDetailBottomViewBlock) {
        self.WeddingCarDetailBottomViewBlock(WeddingCarDetailBottomActionType_buy);
    }
}


@end
